﻿---@diagnostic disable: trailing-space
local extension = Package:new("moepack_token", Package.CardPack)
extension.extensionName = "moepack"

Fk:loadTranslationTable{
  ["moepack_token"] = "萌包衍生牌",
}





--[[

  装备牌
  目录：武器，防具，坐骑，宝具

]]--



local nameless_sword_skill = fk.CreateViewAsSkill{
  name = "nameless_sword_skill",
  attached_equip = "nameless_sword",
  pattern = "slash",
  prompt = "#nameless_sword-prompt",
  card_filter = function(self, to_select, selected)
    if #selected == 1 then return false end
    local card = Fk:getCardById(to_select)
    return card and card.type == Card.TypeEquip and not(card.sub_type == Card.SubtypeWeapon and Fk:currentRoom():getCardArea(to_select) == Player.Equip)
  end,
  view_as = function(self, cards)
    if #cards ~= 1 then return nil end
    local c = Fk:cloneCard("thunder__slash")
    c.skillName = self.name
    c:addSubcards(cards)
    return c
  end,
  enabled_at_response = function(self, player, response) return not response end, -- 只许使用不许打出
}

Fk:addSkill(nameless_sword_skill)

local nameless_sword = fk.CreateWeapon{
  name = "&nameless_sword",
  suit = Card.Club,
  number = 13,
  attack_range = 4,
  equip_skill = nameless_sword_skill,
}

extension:addCards({
  nameless_sword,
})

Fk:loadTranslationTable{
  ["nameless_sword"] = "无名刀",
  [":nameless_sword"] = "装备牌·武器（衍生牌）<br /><b>攻击范围</b>：4<br /><b>武器技能</b>：你可以将一张除装备区的武器牌以外的装备牌当雷【杀】使用。",
  ["nameless_sword_skill"] = "无名刀",
  [":nameless_sword_skill"] = "你可以将一张除装备区的武器牌以外的装备牌当雷【杀】使用。",
  ["#nameless_sword-prompt"] = "无名刀：你可以将一张除装备区的武器牌以外的装备牌当雷【杀】使用",
}




local mithril_dagger_skill = fk.CreateTriggerSkill{
  name = "#mithril_dagger_skill",
  anim_type = "offensive",
  attached_equip = "mithril_dagger",
  priority = 0.1,
  frequency = Skill.Compulsory,
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    local to = player.room:getPlayerById(data.to)
    return target == player and player:hasSkill(self) and data.card.trueName == "slash"
    and (to.hp >= player.hp or to:getHandcardNum() >= player:getHandcardNum())
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(data.to)
    if to.hp >= player.hp then
      data.disresponsiveList = data.disresponsiveList or {}
      table.insertIfNeed(data.disresponsiveList, data.to)
    end
    if to:getHandcardNum() >= player:getHandcardNum() then
      player:drawCards(1, self.name)
    end
  end,
}

Fk:addSkill(mithril_dagger_skill)

local mithril_dagger = fk.CreateWeapon{
  name = "&mithril_dagger",
  suit = Card.Heart,
  number = 3,
  attack_range = 2,
  equip_skill = mithril_dagger_skill,
}

extension:addCards({
  mithril_dagger,
})

Fk:loadTranslationTable{
  ["mithril_dagger"] = "秘银短匕",
  [":mithril_dagger"] = "装备牌·武器（衍生牌）<br /><b>攻击范围</b>：２<br /><b>武器技能</b>：锁定技，每当你使用【杀】指定目标后，若其体力值不小于你，其不可响应；若其手牌数不小于你，你摸一张牌。",
  ["#mithril_dagger_skill"] = "秘银短匕",
}




local kingsbane_skill = fk.CreateTriggerSkill{
  name = "#kingsbane_skill",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.trueName == "slash"
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    for _, id in ipairs(player:getCardIds("e")) do
      local card = Fk:getCardById(id)
      if card.name == "kingsbane" then
        room:setCardMark(card, "kingsbane_extra", card:getMark("kingsbane_extra") + 1)
      end
    end
  end,

  refresh_events = {fk.CardUsing},
  can_refresh = function (self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.trueName == "slash"
  end,
  on_refresh = function(self, event, target, player, data)
    for _, id in ipairs(player:getCardIds("e")) do
      local card = Fk:getCardById(id)
      if card.name == "kingsbane" then
        data.additionalDamage = (data.additionalDamage or 0) + card:getMark("kingsbane_extra")
      end
    end
  end,
}
Fk:addSkill(kingsbane_skill)

local kingsbane = fk.CreateWeapon{
  name = "&kingsbane",
  suit = Card.Spade,
  number = 1,
  attack_range = 1,
  dynamic_attack_range = function(self, player)
    return self:getMark("kingsbane_extra") + 1
  end,
  equip_skill = kingsbane_skill,
  ---@param room Room
  on_uninstall = function(self, room, player)
    Weapon.onUninstall(self, room, player)
    local cardId = self:getEffectiveId()
    if cardId and room:getCardArea(cardId) ~= Card.DrawPile then
      room:moveCards{
        from = room.owner_map[cardId],
        ids = {cardId},
        toArea = Card.DrawPile,
        drawPilePosition = math.random(#room.draw_pile + 1),
        moveReason = fk.ReasonJustMove,
        moveVisible = true,
      }
    end
  end,
}
extension:addCard(kingsbane)

Fk:loadTranslationTable{
  ["kingsbane"] = "弑君",
  [":kingsbane"] = "装备牌·武器（衍生牌）<br /><b>攻击范围</b>：1<br /><b>武器技能</b>：锁定技，每当你使用【杀】后，此武器的攻击范围+1，装备此武器时使用【杀】的伤害基数+1。此牌离开装备区后，保留以上效果并洗入牌堆。",
  ["#kingsbane_skill"] = "弑君",
}


local sun_parasol_skill = fk.CreateTriggerSkill{
  name = "#sun_parasol_skill",
  anim_type = "drawcard",
  attached_equip = "sun_parasol", 
  events = {fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.trueName == "slash" 
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, self.name)
  end,
}

Fk:addSkill(sun_parasol_skill)

local sun_parasol = fk.CreateWeapon{
  name = "&sun_parasol",
  suit = Card.Diamond,
  number = 9,
  attack_range = 3,
  equip_skill = sun_parasol_skill,
}

extension:addCard(sun_parasol)

Fk:loadTranslationTable{
  ["sun_parasol"] = "晴伞",
  [":sun_parasol"] = "装备牌·武器（衍生牌）<br /><b>攻击范围</b>：3<br /><b>武器技能</b>：每当你使用【杀】时，你可以摸一张牌。",
  ["#sun_parasol_skill"] = "晴伞",
}



-- 防具



local rain_umbrella_skill = fk.CreateTriggerSkill{
  name = "#rain_umbrella_skill",
  anim_type = "drawcard",
  attached_equip = "rain_umbrella", 
  priority = 0.1, 
  events = {fk.TargetConfirmed},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card.trueName == "slash" 
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, self.name)
  end,
}

Fk:addSkill(rain_umbrella_skill)

local rain_umbrella = fk.CreateArmor{
  name = "&rain_umbrella",
  suit = Card.Club,
  number = 6,
  equip_skill = rain_umbrella_skill,
}

extension:addCard(rain_umbrella)


Fk:loadTranslationTable{
  ["rain_umbrella"] = "雨伞",
	[":rain_umbrella"] = "装备牌·防具（衍生牌）<br /><b>防具技能</b>：每当你成为【杀】目标后，你可以摸一张牌。",
  ["#rain_umbrella_skill"] = "雨伞",
}









return extension

